{% extends "./blog/base.html"%}
 
{% block main%}
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/kityformula-plugin/addKityFormulaDialog.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/kityformula-plugin/getKfContent.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/kityformula-plugin/defaultFilterFix.js"></script>


<div style="height:50px"></div>
<form class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="" name="upfile">
{% csrf_token %}
    <div class="row">
        <div class="col-md-8">
               <h4 style="color:#ffffff">案例背景与内容</h4>
                <script type="text/plain" id="myEditor" style="width:100%;height:300px;" name="content" value="">
                {{tc.content|safe}}

                </script>
                <script type="text/javascript">
                    var ue =UE.getEditor('myEditor');
                </script>
                
        </div>
        <div class="col-md-4">
        	<div class="row">
	        	<h4 style="color:#ffffff">标题</h4>
	        	<input type="text" class="form-control"  name="title" placeholder="请输入标题" value="{{ tc.title }}" required>

	        	<h4 style="color:#ffffff">封面图片url</h4>
	        	<input type="text" class="form-control"  name="img" placeholder="请输入标题" value="{{ tc.img }}" >
	        	
	        	<h4 style="color:#ffffff">标签(英文逗号分隔)</h4>
	        	<input type="text" class="form-control"  name="tags" placeholder="请输入标签(英文逗号分隔)" value="{{ tc.tags }}" required>

	        	<h4 style="color:#ffffff">摘要</h4>
	        	<textarea class="form-control"  rows="4" name="summary" placeholder="请输入摘要" >{{ tc.summary }}</textarea>
	        </div>

        	<div class="row">
        	{% ifequal request.session.column '1' %}
        	<div style="height:10px"></div>
        	<h4 style="color:#ffffff" class="col-md-4">分类</h4>
        	<div class="col-md-8">
        	<select id="category" name="category"  class="form-control ">
                <option value="应用案例">应用案例</option>
                <option value="代码开源">代码开源</option>
             </select>
             </div>
            {% else %}
            <input type="text" class="form-control"  name="category" placeholder="请输入分类" value="{{ tc.tags }}" required>

        	{% endifequal %}
        	</div>	
        	<div class="row">
        		<h4 style="color:#ffffff" class="col-md-4">发布状态</h4>
        		<h4 style="color:#ffffff" class="col-md-4"><input type="radio" name="status" value='0'>发布</h4>
        		<h4 style="color:#ffffff" class="col-md-4"><input type="radio" name="status" value='1'>草稿</h4>
        	</div>	
        	<input type="text" class="form-control"  name="id" value="{{tc.id}}" style="display:none">

        	<div class="row">
        		<button type="submit" class="btn btn-primary" style="width:100%" >点击提交</button>
                
            </div>      
     
        </div>
    </div>
        
    
</form>
</div>

<script type="text/javascript">
    window.onload=function(){

        // var optElements=document.getElementById("category").children;
        // var optValue="{{ tc.category }}";//这是已知的值
        // for(var opt in optElements){
        //     if(optElements[opt].value==optValue){
        //         optElements[opt].selected="selected";
            
        //     return;
        //     }
        // }
        {% if notice %}
        	alert("{{notice}}")
        {% endif %}
        $("#category").find("option[value='{{tc.category}}']").attr("selected",true);
        $("input[name=status][value='{{tc.status}}']").attr("checked",'checked'); 
    }



</script>





{% endblock %}
